package animator.phantom.renderer.plugin;

import animator.phantom.plugin.*;
import animator.phantom.renderer.param.*;
import animator.phantom.paramedit.*;
import giotto2D.filters.merge.*;
import java.awt.image.*;
import java.awt.geom.*;
import java.awt.*;
import java.util.*;

public class AlphaFilterPlugin extends PhantomPlugin
{
	private AnimatedValue radius;
	private BooleanParam divide;
	private BooleanParam paint;

	public AlphaFilterPlugin()
	{
		initPlugin( FILTER, SINGLE_INPUT );
	}

	public void buildDataModel()
	{
		setName( "AlphaFilter" );

		radius = new AnimatedValue( 0 );
		divide = new BooleanParam( false );
		paint = new BooleanParam( false );

		registerParameter( radius );
		registerParameter( divide );
		registerParameter( paint );
	}

	public void buildEditPanel()
	{
		AnimValueNumberEditor radiusEdit = new AnimValueNumberEditor( "Blur radius", radius );
		CheckBoxEditor divideEdit = new CheckBoxEditor( divide, "Div RBG by Alpha", true );
		CheckBoxEditor paintEdit = new CheckBoxEditor( paint, "Paint Alpha opaque", true );

		addEditor( radiusEdit );
		addRowSeparator();
		addEditor( divideEdit );
		addRowSeparator();
		addEditor( paintEdit );
	}

	public void doImageRendering( int frame )
	{

		BufferedImage img = getFlowImage();
/*
		//--- Alpha operation
		if( paint.get() == true )
		{
			AlphaPaint.filter( img, 255 );
		}
		else if( radius.get( frame ) > 0 || divide.get() == true )
		{
			BufferedImage alphaImg = PluginUtils.createScreenCanvas();
			AlphaToImage.filter( img, alphaImg );
			Graphics2D gc2 = alphaImg.createGraphics();
			gc2.drawImage( alphaImg, f, 0, 0);
			gc2.dispose();

			ImageToAlpha.filter( img, alphaImg );

			if( divide.get() == true )
				DivideByAlpha.filter( img );
		}
*/
		sendFilteredImage( img, frame );
	}

}//end class
